﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Linq;
using System.Threading.Tasks;

namespace Ids4DemoApi1.Controllers
{
    [ApiController]
    [Route("[controller]/[action]")]
    [Authorize]
    public class Ids4Controller : ControllerBase
    {
        public async Task<string> Index()
        {
            Console.WriteLine("************************************************");
            foreach (var item in HttpContext.User.Identities.First().Claims)
            {
                Console.WriteLine($"{item.Type}:{item.Value}");
            }
            Console.WriteLine("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
            
            return await Task.FromResult($"Index");
        }

        [Authorize(Policy = "eMailPolicy")]
        [HttpGet]
        public async Task<string> IndexPolicy()
        {
            return await Task.FromResult($"IndexPolicy");
        }

        [Authorize(Roles = "Admin")]
        public async Task<string> IndexRole()
        {
            return await Task.FromResult($"IndexRole");
        }


        //[AllowAnonymous]
        //public IActionResult IndexToken()
        //{
        //    return View();
        //}

        //[AllowAnonymous]
        //public IActionResult IndexCodeToken()
        //{
        //    //从url读取code---post请求一下Tencent---token
        //    return View();
        //}
    }
}